<template>
  <view class="popup" v-if="show">
    <view class="mask" @tap="close"></view>
    <view class="popup-content">
      <!-- 标题和关闭按钮 -->
      <view class="popup-header">
        <text class="popup-title">活动报名</text>
        <text class="close-btn" @tap="close">✕</text>
      </view>

      <!-- 表单内容 -->
      <view class="form-content">
        <!-- 姓名输入 -->
        <view class="form-item">
          <text class="form-label">姓名</text>
          <input 
            class="form-input" 
            type="text" 
            placeholder="请输入"
            v-model="formData.name"
          />
        </view>

        <!-- 联系电话 -->
        <view class="form-item">
          <text class="form-label">联系电话</text>
          <input 
            class="form-input" 
            type="number" 
            placeholder="请输入"
            v-model="formData.phone"
          />
        </view>

        <!-- 提交按钮 -->
        <button class="submit-btn" @tap="submitForm">提交报名</button>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      formData: {
        name: '',
        phone: ''
      }
    }
  },
  methods: {
    close() {
      this.$emit('close')
    },
    submitForm() {
      // 这里可以添加表单验证逻辑
      if (!this.formData.name || !this.formData.phone) {
        uni.showToast({
          title: '请填写完整信息',
          icon: 'none'
        })
        return
      }
      
      // 提交表单
      this.$emit('submit', this.formData)
      this.close()
    }
  }
}
</script>

<style>
.popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
}

.mask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
}

.popup-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #fff;
  border-radius: 24rpx 24rpx 0 0;
  padding: 30rpx;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30rpx;
}

.popup-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
}

.close-btn {
  font-size: 32rpx;
  color: #999;
  padding: 10rpx;
}

.form-content {
  padding: 20rpx 0;
}

.form-item {
  margin-bottom: 30rpx;
}

.form-label {
  display: block;
  font-size: 28rpx;
  color: #333;
  margin-bottom: 16rpx;
}

.form-input {
  width: 100%;
  height: 80rpx;
  background-color: #f5f5f5;
  border-radius: 8rpx;
  padding: 0 20rpx;
  font-size: 28rpx;
}

.submit-btn {
  width: 100%;
  height: 80rpx;
  line-height: 80rpx;
  background-color: #333;
  color: #fff;
  border-radius: 40rpx;
  font-size: 30rpx;
  font-weight: bold;
  margin-top: 30rpx;
}
</style> 